﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="kflist.aspx.cs" Inherits="UI.system.page.kf.kflist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/system/js/jquery.min.js"></script>
    <script src="/system/layui/layui.js"></script>
    <script src="/system/js/common.js"></script>
    <script src="/system/js/md5.js"></script>
    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
</head>
<body>
    <form id="form1" runat="server">
    <div class="layer-toolbar">
        <div class="layer-toolbar-left">
        <a class="layui-btn layui-btn-small" onclick="Save_Kf(0)">新增客服</a>
        </div>
        <div class="layer-toolbar-right">
            <input id="keyword" type="text" name="title" placeholder="名称" autocomplete="off" class="layui-input" value=""  style="width:150px;" onkeyup='CRM.Enter("#search")'>
            <a id="search" class="layui-btn layui-btn-small layui-btn-normal" onclick="Search()">搜索</a>
            <a class="layui-btn layui-btn-small" onclick="Search()">刷新</a>
        </div>
    </div>
    <div id="iframe" class="layer-iframe">
    <div class="layui-form">
    <table class="layui-table">
    <colgroup>
      <col width="50">
      <col width="100">
      <col>
      <col width="180">
    </colgroup>
    <thead>
      <tr>
        <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
        <th>客服姓名</th>
        <th>客服电话</th>
        <th>操作</th>
      </tr> 
    </thead>
     <tbody id="layer-table">
        <tr><td colspan="12" class="center">数据加载中...</td></tr>
    </tbody>
    <script id="data-table" type="text/html">
      {{#  layui.each(d, function(index, item){ }}
      <tr>
        <td><input type="checkbox" name="" lay-skin="primary"></td>
        <td>{{item.FName}}</td>
        <td>{{item.Mobile}}</td>
        <td>
        <a class="layui-btn layui-btn-mini" onclick="Save_Kf({{item.ID}})">编辑</a>
        <a class="layui-btn layui-btn-mini layui-btn-danger" onclick="Delete_Kf(this,{{item.ID}})">删除</a>
        </td>
      </tr>
      {{#  }); }}
      </script>
  </table>
    </div>
    </div>
    <div id="layer-page" class="layer-page"></div>
    </form>
    <script>
        layui.use('form', function () {
            var $ = layui.jquery, form = layui.form();

            //全选
            form.on('checkbox(allChoose)', function (data) {
                var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
                child.each(function (index, item) {
                    item.checked = data.elem.checked;
                });
                form.render('checkbox');
            });
            Init_Pager(1);
        });

        function Init_Pager(pageindex) {
            var data = {};
            data.act = "Find_Kf";
            data.pageindex = pageindex;
            data.keyword = $("#keyword").val();
            data.sign = GetSign(data.act);
            Loading();
            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    Pager(json.data.list, json.data.count);
                }
                else {
                    LayerBox.Error(json.msg);
                }
            });
        };
        function Save_Kf(id) {
            LayerBox.Loading();
            Ajax.Get("/system/page/kf/kfadd.aspx?id=" + id, function (html) {
                LayerBox.Close.ByAll();
                var title = id == 0 ? "新增" : "修改";
                window.parent.LayerBox.Show(title + "客服", html, 390, 240, null, function (form) {
                    var data = form;
                    data.act = "Save_Kf";
                    data.id = id;
                    data.sign = GetSign(data.act);
                    LayerBox.Loading();
                    Ajax.Post("/tools/Admin.ashx", data, function (r) {
                        var json = $.parseJSON(r);
                        if (json.state) {
                            LayerBox.Success(json.msg, 500, function () {
                                LayerBox.Close.ByAll();
                                if (id == 0) {
                                    $(".layui-laypage").remove();
                                    Init_Pager(1);
                                } else {
                                    var currpage = 1;
                                    if ($(".layui-laypage-curr em").length > 0) {
                                        currpage = $(".layui-laypage-curr em")[1].innerHTML;
                                    }
                                    Init_Pager(currpage);
                                }
                            });
                        }
                        else {
                            LayerBox.Error(json.msg);
                        }
                    });
                });
            });
        };

        function Delete_Kf(o, id) {
            LayerBox.Confirm("您确定要删除吗？", function () {
                Delete_Table(o, id, "Delete_Kf");
            });
        };
</script>
</body>
</html>
